package com.liupf.common.utils;

/**
 * 定义系统常量
 * @author Administrator
 *
 */
public class Constants {
	/** 高级管理员 **/
	public static final String ROLE_SENIOR_MANAGER = "seniorManager";
	/** 中层管理员 **/
	public static final String ROLE_MIDDLE_MANAGER = "middleManager";
	/** 品牌管理员 **/
	public static final String ROLE_BRAND_MANAGER = "brandManager";
	/** 客服中心 **/
	public static final String ROLE_CUSTOMER_CENTER = "customerCenter";
	/** 企业管理员 **/
	public static final String ROLE_ENT_MANAGER = "entManager";
	
	public static final String SESSION_USER_ROLE = "userRole";
	/**
	 * 通过用户角色过滤sql语句
	 * @param sql
	 * @param userRole
	 * @param company
	 * @return
	 */
	public static String appendSqlForRole(String sql,String userRole,String company){
		//品牌操作员或中层管理员
		if(Constants.ROLE_BRAND_MANAGER.equals(userRole) || Constants.ROLE_MIDDLE_MANAGER.equals(userRole)){
			sql +=" and bu.job_number REGEXP '" + company + "[0-9]+'";
		}
		return sql;
	}
	
	public static String appendSqlForRoleCom(String sql,String userRole,String company){
		//品牌操作员或中层管理员
		if(Constants.ROLE_BRAND_MANAGER.equals(userRole) || Constants.ROLE_MIDDLE_MANAGER.equals(userRole)){
			sql +=" and a.source='"+company+"' ";
		}
		return sql;
	}
	
	public static String appendSqlForRoleCity(String sql,String userRole,String cityId){
		//品牌操作员或中层管理员
		if(Constants.ROLE_BRAND_MANAGER.equals(userRole) || Constants.ROLE_MIDDLE_MANAGER.equals(userRole)){
			sql +=" and a.city_id="+cityId+" ";
		}
		return sql;
	}
}
